import{service} from '@/utils/request'

export function getDepartment(id,pageNum,pageSize) {
    return service({
      url: `/api/orgs/depts/searchDeptsByUnivId/${pageNum}/${pageSize}?univId=${id}`,
      method: 'get'
    })
  }

export function searchDeptByName(queryInfo, univId) {
  return service({
    url: `/api/orgs/depts/searchDeptByDeptName/${queryInfo.pageNum}/${queryInfo.pageSize}?deptname=${queryInfo.query}&univId=${univId}`,
    method: 'get'
  })
}

export async function addDept(data) {
  return await service({
    url: `/api/orgs/depts/`,
    method: 'post',
    data
  })
}

export function updateDept(id,data) {
  return service({
    url: `/api/orgs/depts/${id}`,
    method: 'put',
    data
  })
}

export function deleteDept(id,data) {
  return service({
    url: `/api/orgs/depts/${id}`,
    method: 'delete',
    data
  })
}

// 导出Excel表格
export function exportExcel() {
  return service({
    url: `/api/orgs/depts/excel/export`,
    method: 'get',
    responseType: 'blob',
    header: {
      headers: { 'Content-Type': 'application/x-download' }
    },
  })
}